<%@ page import="com.iweb.entity.User" %>
<%@ page import="com.iweb.entity.Product" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: 92460
  Date: 2020/12/18
  Time: 10:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@  taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <title>测试jslt标签</title>
</head>
<%
    List<Product> productList = new ArrayList<>();
    Product product1 = new Product(1, "洗发水", 20.6, 50);
    Product product2 = new Product(2, "沐浴露", 30.6, 30);
    Product product3 = new Product(3, "护发素", 40.6, 20);
    Product product4 = new Product(4, "牙膏", 20.6, 100);
    productList.add(product1);
    productList.add(product2);
    productList.add(product3);
    productList.add(product4);
    request.setAttribute("productList", productList);
%>
<body>
<h2>测试choose标签</h2>
<h2>显示商品标签</h2>
<c:forEach items="${requestScope.productList}"
           var="product"
           varStatus="status">
   <c:choose>
       <c:when test="${(status.index+1)%2==1}">
           <li style="background: #999999">商品名称：${product.name} 商品价格：${product.price} 商品库存：${product.stock}</li>
       </c:when>
       <c:otherwise>
           <li>商品名称：${product.name} 商品价格：${product.price} 商品库存：${product.stock}</li>
       </c:otherwise>


   </c:choose>



</c:forEach>

</body>
</html>